package com.sheep.juc;

import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicStampedReference;

/**
 * @author wangze
 * @date 2020-08-08 20:39.
 **/
public class TSynchronized implements Runnable {
	private  int i = 0;
	private AtomicInteger y=new AtomicInteger(0);


	public  void  increase(){
		//y.addAndGet(1);
		i++;
	}

	@Override
	public  void run() {
		synchronized(Test.class){
			for (int j = 0; j < 10000000; j++) {
				increase();
			}
		}


	}

	public static void main(String[] args) throws InterruptedException {
		TSynchronized tSynchronized = new TSynchronized();

		Thread thread1 = new Thread(tSynchronized);
		Thread thread2 = new Thread(tSynchronized);

		thread1.start();

		thread2.start();

		thread1.join();
		thread2.join();
		//Thread.sleep(5000);
		System.out.println(tSynchronized.i);


	}
	
}
